package com.onlyxiahui.extend.query.hibernate.syntax.data;

/**
 * Description <br>
 * Date 2020-12-11 11:04:02<br>
 * 
 * @author XiaHui [onlovexiahui@qq.com]<br>
 * @since 1.0.0
 */

public enum BindType {
	/**
	 * and
	 */
	and("and", 1),
	/**
	 * or
	 */
	or("or", 2),
	;

	private final int rank;
	private final String value;

	BindType(String value, int rank) {
		this.value = value;
		this.rank = rank;
	}

	public String getValue() {
		return value;
	}

	public int getRank() {
		return rank;
	}

	public boolean isEquals(String value) {
		String s = this.value.replace(" ", "");
		String t = (null != value) ? value.replace(" ", "") : "";
		return s.equalsIgnoreCase(t);
	}

	public static int getRank(String value) {
		int rank = 20;
		for (BindType t : BindType.values()) {
			if (t.isEquals(value)) {
				rank = t.rank;
				break;
			}
		}
		return rank;
	}
}
